import Layout from '@/layout/Layout'

const meta = {requiresAuth: true}

/**
 * 在主框架内显示
 */
const frameIn = [
    {
        path: '/',
        redirect: {name: 'admin.dashboard'},
        component: Layout,
        children: [
            {
                path: 'dashboard',
                name: 'admin.dashboard',
                meta,
                component: () => import('@/pages/index')
            },
            {
                path: 'setting',
                name: 'admin.setting',
                meta,
                component: () => import('@/pages/setting'),
                children: [
                    {
                        path: "/setting/manager",
                        name: "admin.setting.manager",
                        meta,
                        component: () => import('@/pages/setting/manager'),

                    },
                    {
                        path: "/setting/manager/add",
                        name: "admin.setting.manager.add",
                        meta,
                        component: () => import('@/pages/setting/manager/add'),

                    },
                    {
                        path: "/setting/permission",
                        name: "admin.setting.permission",
                        meta,
                        component: () => import('@/pages/setting/permission'),

                    },

                    {
                        path: "/setting/operation",
                        name: "admin.setting.operation",
                        meta,
                        component: () => import('@/pages/setting/logs'),

                    }
                ]
            }
        ]
    },

]

/**
 * 在主框架之外显示
 */
const frameOut = [
    // 页面重定向使用 必须保留
    {
        path: '/redirect/:path*',
        component: {
            beforeCreate() {
                this.$router.replace(JSON.parse(this.$route.params.path))
            },
            render: h => h()
        }
    },
    // 登录
    {
        path: '/login',
        name: 'login',
        component: () => import('@/pages/login')
    }
]


/**
 * 错误页面
 */
const errorPage = [
    // 404
    {
        path: '/403',
        name: '403',
        component: () => import('@/pages/error/403')
    },
    {
        path: '*',
        name: '404',
        component: () => import('@/pages/error/404')
    },

]

// 重新组织后导出
export default [
    ...frameIn,
    ...frameOut,
    ...errorPage
]
